<template>
  <el-table :data="moneyList" stripe style="width: 100%">
    <el-table-column prop="dmoney" label="金额"/>
    <el-table-column prop="duuid" width="300px" label="订单号"/>
    <el-table-column prop="createdate" width="" label="捐赠时间"/>
    <el-table-column prop="dstatus" label="状态" #default="scope">
      {{
        scope.row.dstatus === 1 ? '未支付' : scope.row.dstatus === 2 ? '捐赠成功' : '其他'
      }}
    </el-table-column>
    <el-table-column fixed="right" label="操作" width="180px">
      <template #default="scope">
        <el-button v-if="scope.row.dstatus === 1" @click="continuePay(scope.row.did)" type="primary" size="small"
                   round>继续支付
        </el-button>
      </template>
    </el-table-column>
  </el-table>
  <!--  分页-->
  <div class="pageBox">
    <el-pagination
        :page-size="5"
        small
        background
        layout="prev, pager, next"
        :total="total"
        class="mt-4"
        v-model:current-page="nowPage"
        @update:current-page="getData()"
    />
  </div>
</template>

<script>
import doThis from "@/api/getData";
import {ElMessage} from "element-plus";

export default {
  name: "DonateMoney",
  data() {
    return {
      moneyList: [],
      total: 0,
      nowPage: 1,
    }
  },
  methods: {
    getData() {
      doThis.doGet("/donatemoney/findUser", {pageNum: this.nowPage}).then(res => {
        if (res.code === '0') {
          this.moneyList = res.data.list
          this.total = res.data.count
          console.log(this.moneyList[0])
        } else {
          ElMessage(res.msg)
        }

      })
    },
    continuePay(did) {
      doThis.doGet("/donatemoney/continuePay", {did: did}).then(res => {
        if (res.code === '0') {
          window.open(res.data)
        } else {
          // alert("操作失败")
          ElMessage.error('操作失败')
        }
      })
    },
  },
  mounted() {
    this.$checkLogin()
    this.getData()
  }
}
</script>

<style>

</style>